/**
 * @author casazaft
 */
Package("unit").Class("TestRunner", {
    TestRunner: function(config){    
        var args = config.args||[];
        var fn = config.fn;
        config.scope = config.scope || {};
        config.results = config.results || [];
        config.times = config.times || [];
        var results = config.results;
        var times = config.times;
        this.run = function(){
            var d1, d2, d, total = 0, result;
            while (config.count) {
                d1 = new Date();
                result = fn.apply(config.scope, args);
                d2 = new Date();
                d = d2 - d1;
                times.push(d);
                total += d;
                config.count--;
            }
            results.push(result);
            config.total = total;
            log.info(config.name + " total:" + total);
            return config;
        };
    }
    
});
